package com.cloud.workTest;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class BanChargeConfigTest {
    public static void main(String[] args) {
        LocalDate nowDate = LocalDate.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
        String startTimeStr = "23:10:59";
        String endTimeStr = "06:34:45";
        LocalTime startTime = LocalTime.parse(startTimeStr, formatter);
        LocalTime endTime = LocalTime.parse(endTimeStr, formatter);
        LocalDateTime startDateTime = LocalDateTime.of(nowDate, startTime);
        LocalDateTime endDateTime = LocalDateTime.of(nowDate, endTime);
        if (startDateTime.isAfter(endDateTime)) {
            endDateTime = startDateTime.plusDays(1);
            System.out.println("时间跨天了");
        }
        LocalDateTime nowDateTime = LocalDateTime.now();
        if (nowDateTime.isAfter(startDateTime) && nowDateTime.isBefore(endDateTime)) {
            System.out.println("需要拦截");
        } else {
            System.out.println("不需要拦截");
        }
    }
}
